package error

import "sort"

func maximizeXor(nums []int, queries [][]int) []int {
	result := make([]int, len(queries))
	sort.Ints(nums)
	for index, query := range queries {
		result[index] = -1
		for i := 0; i < len(nums) && nums[i] <= query[1]; i++ {
			result[index] = max(result[index], nums[i]^query[0])
		}
	}
	return result
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
